package com.magnificent.atlantis.client.robot.strategies;

import com.magnificent.atlantis.client.data.task.planner.AbstractPlannerTask;
import com.magnificent.atlantis.client.data.task.planner.CommunityMeetingPlannerTask;
import com.magnificent.atlantis.client.robot.RobotContext;
import com.magnificent.commons.utils.TimeConstants;
import com.magnificent.commons.utils.date.TimePeriod;
import com.magnificent.commons.utils.other.Pair;

import java.util.List;

/**
 * User: Babanin
 * Date: 13.08.2009
 * Time: 1:10:28
 */
public class RobotWorkerStrategy extends RobotStrategy {

    private int iteration;
    private static final int SIMPLE_TASK_ITERATION_VALUE = 90;
    private static final int MEETING_TASK_ITERATION_VALUE = 5;

    public RobotWorkerStrategy(RobotContext robotContext) {
        super(robotContext);

        iteration = 0;
    }

    public void run() {
        while (true) {
            if (iteration % SIMPLE_TASK_ITERATION_VALUE == 0) {
//                generateSimpleTasks(getRandom(5, 10));
            }

            if (iteration % MEETING_TASK_ITERATION_VALUE == 0) {
                generateMeetingTasks(getRandom(1, 3));
            }

            try {
                Thread.sleep(TimeConstants.MLS_IN_SEC);
            } catch (InterruptedException e) {
            }

            iteration++;
        }
    }

    public Pair<AbstractPlannerTask, TimePeriod>[] conflict(AbstractPlannerTask taskA, AbstractPlannerTask taskB, TimePeriod periodA, TimePeriod periodB) {
        return null;
    }

    public TimePeriod newMeetingWithConflictSolutions(CommunityMeetingPlannerTask task, List<TimePeriod> periods) {
        return null;
    }

    public boolean newMeetingWithOutConflict(CommunityMeetingPlannerTask task) {
        return false;
    }

    public String getDescription() {
        return "Worker";
    }
}
